import {getJobGroups} from "@/services/xxlJob/XxlJobCommon";

export default {
  namespace: 'XxlJobCommon',

  state: {
    jobGroupList: [],
  },

  effects: {
    * getJobGroups({payload}, {call, put}) {
      const response = yield call(getJobGroups, payload);
      if (response.code === 0) {
        yield put({
          type: 'chgJobGroupList',
          payload: response.data.map(d => {
            d.key = d.id;
            d.value = d.id;
            d.label = d.title;
            return d;
          }),
        });
      }
    },

  },

  reducers: {
    chgJobGroupList(state, action) {
      return {
        ...state,
        jobGroupList: action.payload,
      };
    },

  }

}
